package de.backtomedieval.scenarios;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import de.backtomedieval.units.UnitSet;
import de.backtomedieval.activities.gamemenu.FightScreen;
import de.backtomedieval.game.Fight;
import de.backtomedieval.game.Player;
import de.backtomedieval.main.Game;

public abstract class AbstractDefendYourCityScenario extends AbstractScenario {

	private UnitSet enemy = new UnitSet(null);
	private long attacksAtRound = 500;
	
	public UnitSet getEnemy() {
		return enemy;
	}

	public void setEnemy(UnitSet enemy) {
		this.enemy = enemy;
	}

	public long getAttacksAtRound() {
		return attacksAtRound;
	}

	public void setAttacksAtRound(long attacksAtRound) {
		this.attacksAtRound = attacksAtRound;
	}
	
	public void onStartFight() {}

	@Override
	public String getDescription() {
		return "Defend your city! The enemy will attack you after " + attacksAtRound + " rounds with " + enemy.toString() + ". To win this scenario, you have to win this fight.";
	}

	@Override
	public boolean checkScenarioGameTimeout(long round) {
		return false;
	}

	@Override
	public boolean checkWinConditions(Game g) {
		if (this.getAttacksAtRound() == Game.getGame().getRoundnr()) {
			UnitSet enemy = this.enemy;
			UnitSet player = Game.getGame().getcCity().getUnits();
			Fight fight = new Fight(player,enemy,Fight.PLAYER_DEFENDS, Game.getGame().getcCity());
			fight.setFinalFight(true);
			fight.start();
		}
		return false;
	}

}
